/* 
 * File:   Context.cpp
 * Author: Gab'z
 * 
 * Created on 25 mai 2012, 13:56
 */

#include "Context.h"
#include "tool/XMLParser.h"
namespace calculator {

    Logger* Context::log = LoggerManager::getInstance()->getLogger("Context");

    Context* Context::instance = 0;

    Context::Context() :
    _inputString(""),
    _error(false),
    _parameters(Parameters::getInstance()),
    _commandMap(CommandMap::getInstance()),
    _mementoCaretaker(MementoCaretaker::getInstance()),
    _stackList(StackList::getInstance()) {
    }

    Context::~Context() {
        MementoCaretaker::deleteInstance();
        StackList::deleteInstance();
        CommandMap::deleteInstance();
        Parameters::deleteInstance();
    }

    void Context::saveContextToXML() const {
        log->trace("saveContextToFile");
        XMLParser* xmlParser = XMLParser::getInstance();
        xmlParser->saveContextToFile(this, calculator::saveFilename);
        XMLParser::deleteInstance();
    }

}